package com.five.monkey.feign.es.service.impl;

import com.five.monkey.feign.es.service.ElasticsearchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
//import org.springframework.data.elasticsearch.core.SearchHit;
//import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.stereotype.Service;

/**
 * @author 狻猊
 * @date 2021-11-24 16:59:36
 */
@Service
public class ElasticsearchServiceImpl implements ElasticsearchService {

    private static final Logger logger = LoggerFactory.getLogger(ElasticsearchServiceImpl.class);

    @Autowired
    private ElasticsearchOperations elasticsearchOperations;

    @Override
    public void test() {
        //Query query = new CriteriaQuery(Criteria.where("status").is(0));
        //SearchHit<User> userSearchHit = elasticsearchOperations.searchOne(query, User.class);
        //assert userSearchHit != null;
        //User user = userSearchHit.getContent();
        //SearchHits<User> userSearchHits = elasticsearchOperations.search(query, User.class);
        //List<User> userList = userSearchHits.get().map(SearchHit::getContent).collect(Collectors.toList());
        //logger.info("===========>user:{}", user);
        //logger.info("===========>userList:{}", userList);
    }

}
